#!/bin/bash
start_time=$(date +%s) # %s可以计算的是1970年以来的秒数

path=../data/ebs_segment_io_records/AY283G_2022-01-01_00:00:00_2022-01-02_00:00:00/device/
#filename=111969901601639.csv
filename="$1"
data_path=${path}${filename}
data_name=${filename%.*}


for executable_file in trace_allGet trace_allPut trace_realRun ; do
  cd ../build/

  # 先删除原有的文件，否则需要sudo
#  rm ../evaluation/${data_name}_${executable_file}_put.txt
#  rm ../evaluation/${data_name}_${executable_file}_16_llsm.txt
#  rm ../evaluation/${data_name}_${executable_file}_16_baseline.txt

#  expr_llsm=../evaluation/${data_name}_${executable_file}_16_llsm.txt
#  sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
#  ./${executable_file} -f ${data_path} -k 16 -v 64 -d ../ssd/db_${data_name}_${executable_file} -w -m 7 -u -i 50 $* --change_level_load > ${expr_llsm}
#  echo run_lsm完成
#
#  expr_baseline=../evaluation/${data_name}_${executable_file}_16_baseline.txt
#  sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
#  ./${executable_file} -f ${data_path} -k 16 -v 64 -d ../ssd/db_${data_name}_${executable_file} -w -m 8 -u -i 50 $* --change_level_load > ${expr_baseline}
#  echo run_baseline完成

  # 计算性能
#  cd ../learned-leveldb/
#  python ./scripts/collect_results.py 1 ${data_name}_${executable_file}_16 > ../evaluation/expr_${data_name}_${executable_file}_16.txt
#  cat ../evaluation/expr_${data_name}_${executable_file}_16.txt


done

# 这个是三种负载都跑完之后测的
cd ../learned-leveldb/
python ./scripts/plot2_iterationDecay.py ${data_name}

newpath=../evaluation_global_${data_name}_tr/
if [ ! -d ${newpath} ]; then
  mkdir ${newpath}
fi
mv ../evaluation_global/* ${newpath}

# 结束，统计时间
end_time=$(date +%s)
cost_time=$((end_time-start_time))
echo "$0" "运行时间：$((cost_time/60))min $((cost_time%60))s"